package kgc.crm.controller;

import kgc.crm.model.User;
import kgc.crm.service.IUserService;
import kgc.crm.util.CommonResult;
import kgc.crm.vo.LoginResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("auth")
@CrossOrigin
public class AuthController {
    @Autowired
    private IUserService userService;

    @PostMapping("login")
    public ResponseEntity<CommonResult<LoginResultVo>> userLogin(
            @RequestBody User user, HttpServletRequest request) {
      return   userService.userLogin(user.getUsername(),user.getPassword(),request);
    }
}
